jQuery(function() 
{ 
    $('#r_relatedname').select2(
    {
    		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
    		ajax: {
    				url: "globals_rel_SearchGlobal",dataType: 'json',type: 'POST',
    				data: function(term, page) 
    				{return {SearchName: term,page: page || 1}},
    				results: function(bond, page) 
    				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
    		},
    		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
    		formatSelection: function(bond){return bond.NAME},
    		initSelection: function(elem, cb){return elem}
    })
    $('#r_name').select2(
	{
		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
		ajax: {
				url: "globals_nik_Search",dataType: 'json',type: 'POST',
				data: function(term, page) 
				{return {SearchName: term,page: page || 1}},
				results: function(bond, page) 
				{return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}}
		},
		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
		formatSelection: function(bond){return bond.NAME},
		initSelection: function(elem, cb){return elem}
    })
	
	$('#vendor_id').select2(
	{
		placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
		ajax: {
				url: "globals_ven_Search",dataType: 'json',type: 'POST',
				/*data:  
					function(a,term, page) {
						return {
							nilai:a,SearchName: term,page: page || 1
						}
					},*/
				data: 
					function(term, page/*, a*/) {
						return {
							SearchName: term,page: page || 1//,nilai:a
						}
					}
					,    
				results: function(bond, page){
							return {
								results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)
								}
						}
		},
		formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
		formatSelection: function(bond){return bond.NAME},
		initSelection: function(elem, cb){return elem}
	})
		
	var a=0;
	for(a=0;a<6;a++){
		$('#vendor_id'+a).select2(
		{
			placeholder: "Search Name",minimumInputLength: 3,multiple: false,quietMillis: 100,allowClear:false,id: function(bond){ return bond.ID;},
			ajax: {
					url: "globals_ven_Search",dataType: 'json',type: 'POST',
					/*data:  
						function(a,term, page) {
							return {
								nilai:a,SearchName: term,page: page || 1
							}
						},*/
					data: 
						function(term, page/*, a*/) {
							return {
								SearchName: term,page: page || 1//,nilai:a
							}
						}
						,    
					results: function(bond, page){
								return {
									results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)
									}
							}
			},
			formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
			formatSelection: function(bond){return bond.NAME},
			initSelection: function(elem, cb){return elem}
		})
	}
	
})

jQuery(function() 
{ 
	var area_name = {area_name:$("#D_Area").val()};
	if(area_name == null)
	{
	
	}
	else
	{
		$('#D_Regional').select2(
		{
			minimumInputLength: 3,multiple: false,quietMillis: 0,id: function(bond){ return bond.AREA_ID;},
			ajax: {
					url: "getfilterRegional",dataType: 'json',type: 'POST',	data: function(term, page) 
					{return {getRegion: term,page: page || 1}},
					results: function(bond, page) 
					{return {results: bond.Show_Region, more: (bond.Show_Region && bond.Show_Region.length == 10 ? true: false)}}
			},
			formatResult: function(bond) {return '<div class="select2-user-result">' + bond.REGIONAL_NAME + '</div>'},
			formatSelection: function(bond){return bond.REGIONAL_NAME},
			initSelection: function(elem, cb){return elem}
		})	
	}
})

jQuery(function() 
{
    $("input[id^='G_Date']").datetimepicker(
	{
		scrollInput:false,closeOnDateSelect:true,datepicker:true,timepicker:false,format:'d/m/Y',minDate:'-1970/01/01',validateOnBlur:false,
		onGenerate:function( ct ){$(this).find('.xdsoft_date.xdsoft_weekend').addClass('xdsoft_disabled');}
	});
});

jQuery(function()
{
    $("input[id^='G_Time']").datetimepicker(
	{
		scrollInput:false,closeOnDateSelect:true,datepicker:false,timepicker:true,format:'H:i',validateOnBlur:false,
		allowTimes:['07:00','07:30','08:30','09:00','09:30','10:00','10:30','11:00','12:00','12:30','13:00','13:30','14:00','14:30','15:00','15:30','16:00','16:30','17:00']
	});
});